package com.yanqu.road.entity.activity.washe.eliminate;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class WasheGameData {

    private int sceneId;

    private List<List<WasheBlock>> blockList;

    // 格子边框    key：y，x
    private Map<Integer, Map<Integer, WasheBlock>> frameMap = new ConcurrentHashMap<>();

    // 计数
    private int scene05Count;
    private int scene12Color;
    private int scene12Score;
    private int scene13Count;
    private int scene04Count;
    private int scene08Count;
    private int scene07Count;
    private List<WasheBlock> scene07StageBoxList = new ArrayList<>();

    // =========================

    public WasheGameData clone() {
        WasheGameData gameData = new WasheGameData();

        List<List<WasheBlock>> listList = new ArrayList<>();
        for (List<WasheBlock> tmpList : blockList) {
            List<WasheBlock> list = new ArrayList<>();
            for (WasheBlock tmpBlock : tmpList) {
                list.add(tmpBlock.clone());
            }
            listList.add(list);
        }
        gameData.setBlockList(listList);

        gameData.setSceneId(sceneId);
        gameData.setScene05Count(scene05Count);
        gameData.setScene12Color(scene12Color);
        gameData.setScene12Score(scene12Score);
        gameData.setScene13Count(scene13Count);
        gameData.setScene04Count(scene04Count);
        gameData.setScene08Count(scene08Count);
        gameData.setScene07Count(scene07Count);

        for (Map<Integer, WasheBlock> map : frameMap.values()) {
            for (WasheBlock frame : map.values()) {
                gameData.getFrameMap().putIfAbsent(frame.getY(), new ConcurrentHashMap<>());
                gameData.getFrameMap().get(frame.getY()).put(frame.getX(), frame.clone());
            }
        }

        for (WasheBlock block : scene07StageBoxList) {
            gameData.getScene07StageBoxList().add(block.clone());
        }

        return gameData;
    }

    public static WasheGameData createWasheGameData(int appointSceneId, List<List<WasheBlock>> blockList) {
        WasheGameData gameData = new WasheGameData();
        gameData.setSceneId(appointSceneId);
        gameData.setBlockList(blockList);
        return gameData;
    }

    public void addFrame(WasheBlock frame) {
        frameMap.putIfAbsent(frame.getY(), new ConcurrentHashMap<>());
        frameMap.get(frame.getY()).put(frame.getX(), frame);
    }

    // =========================

    public int getSceneId() {
        return sceneId;
    }

    public void setSceneId(int sceneId) {
        this.sceneId = sceneId;
    }

    public List<List<WasheBlock>> getBlockList() {
        return blockList;
    }

    public void setBlockList(List<List<WasheBlock>> blockList) {
        this.blockList = blockList;
    }

    public int getScene05Count() {
        return scene05Count;
    }

    public void setScene05Count(int scene05Count) {
        this.scene05Count = scene05Count;
    }

    public int getScene12Color() {
        return scene12Color;
    }

    public void setScene12Color(int scene12Color) {
        this.scene12Color = scene12Color;
    }

    public int getScene13Count() {
        return scene13Count;
    }

    public void setScene13Count(int scene13Count) {
        this.scene13Count = scene13Count;
    }

    public int getScene04Count() {
        return scene04Count;
    }

    public void setScene04Count(int scene04Count) {
        this.scene04Count = scene04Count;
    }

    public Map<Integer, Map<Integer, WasheBlock>> getFrameMap() {
        return frameMap;
    }

    public void setFrameMap(Map<Integer, Map<Integer, WasheBlock>> frameMap) {
        this.frameMap = frameMap;
    }

    public int getScene08Count() {
        return scene08Count;
    }

    public void setScene08Count(int scene08Count) {
        this.scene08Count = scene08Count;
    }

    public int getScene07Count() {
        return scene07Count;
    }

    public void setScene07Count(int scene07Count) {
        this.scene07Count = scene07Count;
    }

    public int getScene12Score() {
        return scene12Score;
    }

    public void setScene12Score(int scene12Score) {
        this.scene12Score = scene12Score;
    }

    public List<WasheBlock> getScene07StageBoxList() {
        return scene07StageBoxList;
    }

    public void setScene07StageBoxList(List<WasheBlock> scene07StageBoxList) {
        this.scene07StageBoxList = scene07StageBoxList;
    }
}
